//
//  ModuleAPageRouter.swift
//  NCRouterBus
//
//  Created by zhanwenyan on 2018/10/17.
//  Copyright © 2018年 Newcoretech. All rights reserved.
//

import UIKit

class ModuleAPageRouter: NCModuleRouter {
    
    private init() {}
    
    static func shared() -> ModuleAPageRouter {
        return ModuleAPageRouter()
    }
    
    func routePage(url: URL?, params: [String : Any]?, onResult: (([String : Any]?) -> Void)?, skipType: PageSkipType) -> UIViewController? {
        if url?.scheme == "ModuleA" && url?.host == "page" {
            let isPresent: Bool
            switch skipType {
            case .push:
                isPresent = false
            case .present:
                isPresent = true
            }
            switch url?.path {
            case "/ModuleAViewController":
                return ModuleAViewController.init(params: params, onResult: onResult, isPresent: isPresent)
            default:
                return nil
            }
        }
        return nil
    }
    
    func hasRoute(url: URL?) -> Bool {
        if url?.scheme == "ModuleA" && url?.host == "page" {
            switch url?.path {
            case "/ModuleAViewController":
                return true
            default:
                return false
            }
        } else {
            return false
        }
    }
    

//    static let instance = ModuleAPageRouter()
//
//    static func shared() -> ModuleAPageRouter {
//        return instance
//    }
//
//    func hasRoute(url: URL?) -> Bool {
//        if(url?.scheme == "ModuleA") {
//            if(url?.host == "page") {
//                if(url?.path == "/ModuleAViewController") {
//                    return true
//                }
//            }
//        }
//        return false
//    }
//
//    func routePage(url: URL?, params: [String : Any]?, onResult: ((NSDictionary?) -> Void)?, isPresent: Bool) -> UIViewController? {
//        if(url?.scheme == "ModuleA" && url?.host == "page") {
//            if(url?.path == "/ModuleAViewController") {
//                return ModuleAViewController.initWith(params: params, onResult: onResult, isPresent: isPresent)
//            }
//        }
//        return nil
//    }
}
